package org.megha.blog.example.part12;

import java.util.HashSet;
import java.util.Set;

public class SetExample {

	public static void main(String args[]) {
		// creates a new hash set
		Set<String> set = new HashSet<String>();
		set.add("Monday");
		set.add("Tuesday");
		set.add("Wednesday");

		for (String s : set) {
			System.out.println(s);
		}

		set.add("Thursday");
		System.out.println("size after adding Thursday is " + set.size());

		set.add("Tuesday");
		System.out.println("size after attempt to add duplicate: " + set.size());
		// size does not change by adding a duplicate value

		System.out.println("is set empty? " + set.isEmpty());
		System.out.println("does it have Monday? " + set.contains("Monday"));
		System.out.println("emptying set");
		set.clear();

		System.out.println("is set empty? " + set.isEmpty());
		System.out.println("does it have Monday? " + set.contains("Monday"));
	}

}
